﻿/*
	Copyright © Bogdan Kobets 2011
	http://ElasticLogic.com
*/

using System;
using ElasticLogic.TagsMarker.Concepts;

namespace ElasticLogic.TagsMarker.Filter
{

	public sealed class NOT : FilterRule
	{
		public FilterRule Value { get; private set; }

		public override string Expression
		{
			get { return "!" + Value.Expression; }
		}

		public NOT(FilterRule value)
			: base(FilterMode.NOT)
		{
			this.Value = value;
		}

		public NOT(Label label)
			: this(new NOOP(label))
		{
		}

		internal override void ResetSatisfy()
		{
			Value.ResetSatisfy();
			base.Satisfy = null;
		}

		public override FilterRule CloneRule()
		{
			return new NOT(Value.CloneRule());
		}

		#region Operators overloading

		public static FilterRule operator !(NOT negative)
		{
			return negative.Value.CloneRule();
		}

		#endregion Operators overloading

	}

}
